{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "b02fa528",
   "metadata": {},
   "source": [
    "# 1. request（让https服务人类）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "92711c12",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8693ad85",
   "metadata": {},
   "source": [
    "* r是指 response"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "e23088df",
   "metadata": {},
   "outputs": [],
   "source": [
    "r = requests.get(\"https://cn.bing.com\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "7285b88a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b64c3944",
   "metadata": {},
   "source": [
    "* r.content \n",
    "> 1.可以获取请求数据内容（观察页面数据形态 HTML,Json)\n",
    "> 2. b 是指 bytes ：二进制文件\n",
    "* r.json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "5ca40c25",
   "metadata": {},
   "outputs": [],
   "source": [
    "r = requests.get(\"http://httpbin.org/get\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c210437b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "5e0c408f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'{\\n  \"args\": {}, \\n  \"headers\": {\\n    \"Accept\": \"*/*\", \\n    \"Accept-Encoding\": \"gzip, deflate\", \\n    \"Host\": \"httpbin.org\", \\n    \"User-Agent\": \"python-requests/2.25.1\", \\n    \"X-Amzn-Trace-Id\": \"Root=1-622dbda6-3bde3bbf66adde2426d9ae40\"\\n  }, \\n  \"origin\": \"120.85.142.177\", \\n  \"url\": \"http://httpbin.org/get\"\\n}\\n'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.content"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ed2383f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'args': {},\n",
       " 'headers': {'Accept': '*/*',\n",
       "  'Accept-Encoding': 'gzip, deflate',\n",
       "  'Host': 'httpbin.org',\n",
       "  'User-Agent': 'python-requests/2.25.1',\n",
       "  'X-Amzn-Trace-Id': 'Root=1-622dbda6-3bde3bbf66adde2426d9ae40'},\n",
       " 'origin': '120.85.142.177',\n",
       " 'url': 'http://httpbin.org/get'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json() #将json数据转换成字典"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "69646582",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'{\\n  \"args\": {}, \\n  \"headers\": {\\n    \"Accept\": \"*/*\", \\n    \"Accept-Encoding\": \"gzip, deflate\", \\n    \"Host\": \"httpbin.org\", \\n    \"User-Agent\": \"python-requests/2.25.1\", \\n    \"X-Amzn-Trace-Id\": \"Root=1-622dbda6-3bde3bbf66adde2426d9ae40\"\\n  }, \\n  \"origin\": \"120.85.142.177\", \\n  \"url\": \"http://httpbin.org/get\"\\n}\\n'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.content"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddcb6c8b",
   "metadata": {},
   "source": [
    "* 3. payload  \n",
    "  使用payload来实现请求数据传递"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b9671c29",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-11-503cb097248b>, line 3)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-11-503cb097248b>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m    'JOB':'it'\u001b[0m\n\u001b[1;37m         ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "payload = {\n",
    "    'name':'zhichao'\n",
    "    'JOB':'IT'\n",
    "}\n",
    "\n",
    "r =  requests.get(\"https://httpbin.org/get\",params = payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "e2398d98",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [200]>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "65edfadf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'args': {},\n",
       " 'headers': {'Accept': '*/*',\n",
       "  'Accept-Encoding': 'gzip, deflate',\n",
       "  'Host': 'httpbin.org',\n",
       "  'User-Agent': 'python-requests/2.25.1',\n",
       "  'X-Amzn-Trace-Id': 'Root=1-622dbda6-3bde3bbf66adde2426d9ae40'},\n",
       " 'origin': '120.85.142.177',\n",
       " 'url': 'http://httpbin.org/get'}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "faf77371",
   "metadata": {},
   "source": [
    "# 2. face++ detect"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88740408",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 准备base_url （对应该功能的url链接）\n",
    "face_detect_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "\n",
    "# 2.准备参数数据 \n",
    "payload = {\n",
    "    ''\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64cc66d2",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
